<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/17 0017
 * Time: 13:33
 */

namespace app\common\validate;

use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'username|用户名' => 'require',
        'password|密码' => 'require',
        'oldpassword|原密码' => 'require',
        'newpassword|新密码' => 'require'
    ];

    public function sceneLogin()
    {
        return $this->only(['username', 'password']);
    }

    public function sceneAdd()
    {
        return $this->only(['username', 'password'])
            ->append('username', 'unique:admin');
    }

    public function sceneEdit()
    {
        return $this->only(['oldpassword', 'newpassword']);
    }
}